package com.taptech.doufu.presenter.user

import android.app.Activity
import android.content.Intent
import com.taptech.doufu.constant.Constant
import com.taptech.doufu.model.novel.bean.NovelAttentionBean
import com.taptech.doufu.model.user.UserDetailBean
import com.taptech.doufu.model.user.UserDetailModel
import com.taptech.doufu.model.user.UserPosterBean
import com.taptech.doufu.net.retrofit.api.BaseSubscriber
import com.taptech.doufu.presenter.BasePresenter
import com.taptech.doufu.ui.activity.UserDetailActivity

class UserPosterPresenter(activity: Activity, view: IUserPosterView, val intent:Intent) : BasePresenter<IUserPosterView>(activity, view) {
    val model = UserDetailModel(activity)
    val uid = intent.getIntExtra(Constant.UID,0)
//    private val data = intent.getSerializableExtra(Constant.DATA) as UserPosterBean

    fun getUserPoster() {
        model.getUserPoster(uid,object :BaseSubscriber<UserPosterBean>(){
            override fun onNext(t: UserPosterBean?) {
                super.onNext(t)
                if (t != null) {
                    mView.getUserPosterResult(true,t)
                }else{
                    mView.getUserPosterResult(false, UserPosterBean())
                }
            }

            override fun onError(e: Throwable?) {
                super.onError(e)
                mView.getUserPosterResult(false, UserPosterBean())
            }
        })
    }

}